package com.dd.stack.file.pojo.req;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dd.stack.common.util.param.PageParams;
import com.dd.stack.file.pojo.DO.FileDO;
import com.dd.stack.file.pojo.params.FileQueryParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Author liuxianmeng
 * @CreateTime 2025/5/11 16:22
 * @Description 文件分页请求类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("文件分页请求类")
public class FilePageReq {
    @ApiModelProperty("分页请求参数")
    private PageParams pageParams;
    @ApiModelProperty("文件查询请求参数")
    private FileQueryParams fileQueryParams;

    // 构建查询条件
    public LambdaQueryWrapper<FileDO> buildLambdaQueryWrapper() {
        LambdaQueryWrapper<FileDO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        // DO查询参数
        if (fileQueryParams != null) {
            if (fileQueryParams.getFileName()!= null) {
                lambdaQueryWrapper.like(FileDO::getFileName, fileQueryParams.getFileName());
            }
        }
        // 根据数据库Id进行排序
        return lambdaQueryWrapper.orderByAsc(FileDO::getId);
    }
}

